package cn.tarena.ht.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import cn.tarena.ht.pojo.Role;

public interface RoleMapper {
	
	@Select("select * from role_p order by order_no")
	public List<Role> findAll();
	
	public void saveRole(Role role);
	
	@Delete("delete from role_p where role_id = #{roleId}")
	public void deleteRole(String roleId);
	
	@Select("select * from role_p where role_id = #{roleId}")
	public Role findRole(String roleId);
	
	public void updateRole(Role role);
	
	public void deleteRoleById(String[] userIds);
	
	@Delete("delete from role_user_p where role_id = #{roleId}")
	public void deleteUserRole(String roleId);

	@Insert("insert into role_module_p (module_id, role_id) values (#{moduleId},#{roleId})")
	public void saveRoleModule(@Param("roleId")String roleId, @Param("moduleId")String moduleId);

	@Select("select module_id from role_module_p where role_id = #{roleId}")
	public List<String> findModules(String roleId);

	@Delete("delete from role_module_p where role_id = #{roleId}")
	public void deleteRoleModule(String roleId);
}
